package com.example.tvwanandroid.retrofit

import com.example.tvwanandroid.base.BaseBean
import com.example.tvwanandroid.base.BaseListResult
import com.example.tvwanandroid.base.BaseResult
import com.example.tvwanandroid.bean.*
import io.reactivex.Observable
import okhttp3.RequestBody
import retrofit2.Call
import retrofit2.http.*


interface ApiServer {
    //首页文章列表
    @GET("/article/list/{page}/json")
    fun articleList(@Path("page") page:Int) : Observable<BaseResult<ArticleListBean>>

    @GET("/article/list/{page}/json")
    fun articleLists(@Path("page") page:Int) : Call<List<ArticleListBean>>

    //首页广告
    @GET("/banner/json")
    fun banner():Observable<BaseListResult<BannerBean>>

    //搜索热词
    @GET("/hotkey/json")
    fun hotkey(): Observable<BaseListResult<HotkeyBean>>

    //体系接口
    @GET("/tree/json")
    fun tree(): Observable<BaseListResult<KnowledgeBean.DataBean>>

    //知识体系下的文章
    @GET("article/list/{page}/json")
    fun article(@Path("page") page: Int,@Query("cid") cid: Int): Observable<BaseResult<ArticleListBean>>

    //导航
    @GET("/navi/json")
    fun navi():Observable<BaseListResult<NavigationBean.DataBean>>

    //项目分类
    @GET("/project/tree/json")
    fun projectTree(): Observable<BaseListResult<ProjectTitleBean.DataBean>>

    //项目分类下的列表
    @GET("/project/list/{page}/json")
    fun projectList(@Path("page") page: Int,@Query("cid") cid:Int): Observable<BaseBean<ProjectListBean>>

    //登录
    @POST("/user/login")
    @FormUrlEncoded
    fun login(@Field("username") username: String, @Field("password") password:String):Observable<BaseBean<LoginBean>>

    //注册
    @POST("/user/register")
    @FormUrlEncoded
    fun register(@Field("username") username: String, @Field("password") password: String, @Field("repassword") repassword: String) : Observable<BaseBean<RegisterBean>>

    //收藏文章列表
    @GET("/lg/collect/list/0/json")
    fun collect():Observable<BaseBean<*>>

    //收藏站内文章
    @POST("/lg/collect/1165/json")
    @FormUrlEncoded
    fun collectLg(@Path("id") id:Int):Observable<BaseBean<*>>

    //收藏站外文章
    @POST("/lg/collect/add/json")
    @FormUrlEncoded()
    fun collectadd():Observable<BaseBean<*>>

    //取消收藏
    @POST("/lg/uncollect_originId/2333/json")
    @FormUrlEncoded
    fun uncollect(@Path("id") id:Int):Observable<BaseBean<*>>

    //我的收藏
    @POST("/lg/uncollect/2805/json")
    @FormUrlEncoded
    fun mycollect(@Path("id") id: Int,@Path("orignId") orignId:Int ) :Observable<BaseBean<*>>

    //收藏网站列表
    @GET("/lg/collect/usertools/json")
    fun usertools():Observable<BaseBean<*>>


    //收藏网址
    @POST("/lg/collect/addtool/json")
    @FormUrlEncoded
    fun addcollect(@Path("name") name: Int,@Path("link") link: Int):Observable<BaseBean<*>>

    //编辑收藏网站
    @POST("/lg/collect/updatetool/json")
    @FormUrlEncoded
    fun updatetool(@Path("id") id: Int,@Path("name") name:Int,@Path("link") liml:Int):Observable<BaseBean<*>>

    //删除收藏网站
    @POST("/lg/collect/deletetool/json")
    @FormUrlEncoded
    fun deletetool(@Path("id") id: Int):Observable<BaseBean<*>>

    //搜索
    @POST("/article/query/{page}/json")
    @FormUrlEncoded
    fun query(@Path("page") page: Int, @Field("k") k:String):Observable<BaseBean<SearchBean>>

    //新增一个TODO
    @POST("/lg/todo/add/json")
    @FormUrlEncoded
    fun add(@Path("title") title:Int,@Path("content") content:Int,@Path("date") date:Int,@Path("type") type: Int):Observable<BaseBean<*>>

    //更新一条todo内容
    @POST("/lg/todo/update/83/json")
    @FormUrlEncoded
    fun update(@Path("id") id: Int,@Path("title") title: Int,@Path("content") content: Int,@Path("date") date: Int,
               @Path("status") status: Int,@Path("type") type: Int):Observable<BaseResult<*>>

    //删除一条todo
    @POST("/lg/todo/delete/83/json")
    @FormUrlEncoded
    fun delete(@Path("id") id: Int, @Path("status") status: Int):Observable<BaseResult<*>>

    //未完成TODO列表
    @POST("/lg/todo/listnotdo/")
    @FormUrlEncoded
    fun listnotdo(@Path("type") type: Int,@Path("page")page: Int):Observable<BaseResult<*>>

    //已完成TODO列表
    @POST("/lg/todo/listdone/")
    @FormUrlEncoded
    fun listdone(@Path("type") type:Int,@Path("page") page:Int):Observable<BaseResult<*>>

    // 仅更新完成状态Todo
    @POST("/lg/todo/done/80/json")
    @FormUrlEncoded
    fun done(@Path("id") id:Int):Observable<BaseResult<*>>

    @POST("/uc/mobile/code")
    fun getSendCode(@Body body: CodeBean):Observable<BaseCodeBean<Any>>
}